<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<meta HTTP-EQUIV="expires" CONTENT="0">
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<title>_${customer.customerName}_拣货单预览</title>
<script language="javascript" type="text/javascript" src="${ctx}/static/datepicker/WdatePicker.js"></script>
<script type="text/javascript">

   //获取拣货信息
  function getInfo(stockInfo,part) {
  
       var stockInfoSplit=stockInfo.split("_");
       var temp='';
       if( part=='sku' ){
          temp=stockInfoSplit[2];
       }else if(part=='stockCode'){
         temp=stockInfoSplit[0];
       }else if(part=='boxCode'){
         temp=stockInfoSplit[1];
       }
       return temp;
       
	}
//---------------打印拣货单----------------
	function AjaxPagePrinter(){
		printName = $("#pickPickPrint").val();
		showBg();
		$.ajax({
			type : 'post',
			url : '${ctx}/pickTask/ajaxPrintPickInfo',
			data : {
				taskCode : taskCode
			},
			dataType : 'json',
			success : function(data){
				if(data.status == "1"){
					printPickInfo(data.taskItemList,printName);
					closeBg();
				}else{
					alert("打印加载错误！");
				}
			}
		});
	}
	function printPickInfo(taskItem,printName){
		LODOP.PRINT_INIT(printName);
		var taskCode = taskItem[0].taskCode;
		var adjustTop = 0;
	 	var adjustLeft = 0;
		var str = '';
		var num = 0;
		LODOP.ADD_PRINT_BARCODE((10+adjustTop)+"mm", "65%", "45mm", "10mm", "128Auto", taskCode);
		str +="<table width='100%' height='100%' cellpadding='0' cellspacing='0' align = 'center' border='1'>";
		str +="<tr><td colspan= '7' align = 'center'><h3>拣货单(任务编号："+taskCode+")</h3></td></tr>";
		str +="<tbody align = 'center'><tr><td colspan= '2'>仓库</td><td colspan= '2'>"+taskItem[0].warehouseCode+"</td></tr>";
		str += "<tr style='font-size:10pt'><td width='10%'>序号</td><td width='10%'>商家</td><td width='15%'>库位</td><td width='15%'>箱位</td><td width='20%'>sku</td><td width='20%'>sku名称</td><td width='10%'>数量</td></tr>";
		for(var i =0;i<taskItem.length;i++){
			str +="<tr style='font-size:14pt' ><td>"+(i+1)+"</td><td>"+taskItem[i].customerCode+"</td><td>"+taskItem[i].stockCode+"</td><td>"+taskItem[i].boxCode+"</td><td>"+taskItem[i].sku+"</td><td>"+taskItem[i].skuName+"</td><td>"+taskItem[i].num+"</td></tr>";
			num += taskItem[i].num;
		}
		str +="</tbody>";
		str +="<tfoot align = 'center'><tr><td colspan= '6'><h4>拣货单(任务编号："+taskCode+")</h4></td><td>"+num+"</td></tr></tfoot>";
		str +="</table>";
		LODOP.SET_PRINT_PAGESIZE(1, 0, 0, $("#paperSizes").val()) ;
		LODOP.ADD_PRINT_TABLE(10,0, "100%","100%",str);
		if (LODOP.SET_PRINTER_INDEXA(printName)) {
			LODOP.PRINT(); 
		}
	}
</script>
</head>

<body>
<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">拣货单信息预览</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				

    <!-- 任务信息 -->
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
<!-- 	    <thead> -->
<!-- 			<th style="vertical-align: middle; color: white; " colspan="11" bgcolor="#8EB4CB">拣货单信息预览</th> -->
<!-- 		</thead> -->
		<thead><tr>
		        <th>批次编号</th>
			    <th>任务编号</th>
			    <th>商家</th>
			    <th>仓库</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		      <tr>
		         <td>${task.batchCode}</td>
		         <td>${task.taskCode}</td>
		         <td>${task.customerCode}</td>
		         <td>${task.warehouseCode}</td>
		         <td>
		           <a href="${ctx}/pickTask/exportExcel_multi/${task.taskCode}"  role="button" class="btn btn-primary" >导出</a>
		         	<!-- <a href="#printPickInfo"  data-toggle="modal" role="button" class="btn btn-primary" onclick="changeStatus('${task.taskCode}')">打印</a> -->
		         </td>
		      </tr>
		</tbody>
	</table>
	</div></div></div></div>
	
	
	<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">拣货单信息预览</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				
	<!-- 拣货信息预览 -->
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
<!-- 	    <thead> -->
<!-- 			<th style="vertical-align: middle; color: white; " colspan="11" bgcolor="#8EB4CB">拣货单信息预览</th> -->
<!-- 		</thead> -->
		<thead><tr>
			    <th>序号</th>
			    <th>库位</th>
			    <th>箱位</th>
			    <th>sku</th>
			    <th>数量</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${printInfoList}" var="o" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td><script type="text/javascript">document.write(getInfo('${o.key}','stockCode'));</script></td>
			   <td><script type="text/javascript">document.write(getInfo('${o.key}','boxCode'));</script></td>
			   <td><script type="text/javascript">document.write(getInfo('${o.key}','sku'));</script></td>
			   <td>${o.value}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</div></div></div></div>
	<div class="modal  fade"tabindex="-1" role="dialog" aria-labelledby="myModalLabel"	aria-hidden="true" id="printPickInfo">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<h3 id="myModalLabel">
		                                                        打印拣货单信息
						</h3>
						<span id="messageLable"></span>
					</div>
					<div class="modal-body" style="overflow: auto;">
						<div class="control-group">
							<div class="controls">
								  选择打印机:
								<select id="pickPickPrint" name="packFormPrinter" style="width: 300px">
		
								</select>
							</div>
							<div class="controls">
								  纸张的格式:
								<select id="paperSizes" name="paperSizes" class="form-control" style="width: 300px" >
											<option value="A4" selected="selected" >A4</option>
											<option value="A5" >A5</option>
								</select>
							</div>
						</div>
					</div>
					
		               <div class="modal-footer">
						<a class="btn btn-primary" data-dismiss="modal" aria-hidden="true" onclick="AjaxPagePrinter()"> 立即打印 </a>
						<a class="btn" data-dismiss="modal" aria-hidden="true"> 关闭 </a>
					  </div>
		  	</div>
		  </div>
		</div>
</section>
	
	<script type="text/javascript">
		var taskCode = '';
		function changeStatus(task){
			taskCode = task;
			packFormPrinter("pickPickPrint");
		}
	
	</script>
</section>

</body>
</html>
